<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../jquery-3.3.1.min.js"></script>
    <style>
        .left {
            width: 80px;
            height: 150px;
            background-color: blue;
            position: fixed;
            _position: absolute;
            left: 0px;
            top: 0px;
        }
        
        .right {
            width: 80px;
            height: 150px;
            background-color: red;
            position: fixed;
            _position: absolute;
            right: 0px;
            top: 0px;
        }
    </style>
</head>

<body>
    <div class="left" id="left">左</div>
    <div class="right" id="right">右</div>
    <div style="height: 2000px;width: 500px;margin: 0 auto; background-color: blueviolet;"></div>
    <script>
        var bheight = document.documentElement.clientHeight || document.body.clientHeight;
        window.onscroll = window.onresize = window.onload = function() {

            $("#left").css("top", (bheight - 150) / 2 + "px");
            $("#right").css("top", (bheight - 150) / 2 + "px");
        }
    </script>
</body>

</html>